#ifndef __CATIMERH__
#define __CATIMERH__

#include "calist.h"

#ifndef ANDROID
#include <sys/timerfd.h>
#else
#include "timerfdport.h"
#endif

//#define TIMER_MEM_ALLOC


 struct es_t;
 struct evt_t;

typedef struct catimer_t
{
	lklist list;
	int fd;
	unsigned int msec;
	void* user;
	void (*timercb)(catimer_t* ptimer, void* user);
	es_t* psys;
	evt_t* pevt;
} catimer_t;

typedef struct 
{
	lklist list;
	catimer_t t;
} estimer_t;


typedef void (*TIMERCB)(catimer_t* ptimer, void* user);

catimer_t*  catimer_open(es_t* psys, catimer_t* ptimer, unsigned int msec, TIMERCB cb, void* user);
void catimer_close(catimer_t* ptimer);
void catimer_set(catimer_t* ptimer, unsigned int msec);
void catimer_reset(catimer_t* ptimer);

int es_set_timer(es_t* psys, int tid, unsigned int msec, TIMERCB cb);
void es_kill_timer(es_t* psys, int tid);


#endif

